class HomeController < ApplicationController
  def index
    @latest_video = Video.find(:all, :order => "created_at").last
    @popular = Video.find(:all, :order => "created_at", :limit => 5)
    @computer_videos = Video.find(:all, :order => "created_at", :limit => 5)
    @science_videos = Video.find(:all, :order => "created_at", :limit => 5)
    @channels = Channel.find(:all, :order => "title")
    @user = current_user
    
  end
  
  def news
    @articles = Article.find(:all, :order => "created_at", :limit => 7)
  end
  
  def navbar
    @channels = Channel.find(:all, :order => "title")
  end
  
  def contact
    @channels = Channel.find(:all, :order => "title")
    @popular = Video.find(:all, :order => "created_at", :limit => 5)
  end
  
  def send_contact_mail
    Notifier.send_contact_mail(params[:name], params[:email], params[:message]).deliver 
    redirect_to "/home", :notice => "Thanks for sending mail to us"
  end
end
